
<style>
    .description { color: #999; font-size: 13px; }
    .send-item-list li, .send-pet-list li { margin: 8px 0; }
    .send-item-list li .form-control, .send-pet-list li .form-control { margin-right: 2px; }
    .tools-btn { padding: 5px 7px; border-radius: 12px; }
    .div_item_name{float: left;}
    .div_item_id{float: left;}
    form{margin-bottom: 300px;}
</style>

<form method="post" action="/oss/?r=replyTemplate/doEdit">
    <{include file='../common_params.tpl'}>
    <input type="hidden" name="id" value="<{$info.id}>" />
    <div class="box box-black">
        <div class="box-body">
        	<h5> <i class="fa fa-users"></i>&nbsp;&nbsp;信息</h5>
            <table class="table table-bordered">
                <colgroup>
                    <col style="width: 20%;"></col>
                    <col style="width: 80%;"></col>
                </colgroup>
                
                <tr>
                    <th class="th-label">名称</th>
                    <td><input type="text" class="form-control inline" name="name" value="<{$info.name}>" /></td>
                </tr>
                
                <tr>
                    <th class="th-label">邮件标题</th>
                    <td><input type="text" class="form-control inline" name="title" value="<{$info.title}>"/></td>
                </tr>

                <tr>
                    <th class="th-label">邮件内容</th>
                    <td><textarea class="form-control" name="content" rows="5"><{$info.content}></textarea></td>
                </tr>
    
                <tr>
                    <th class="th-label">是否发送道具</th>
                    <td>
                    	<div style="padding-top: 5px;">
                    		<input type="radio" name="is_send_good" id="is_send_good1" value="1" <{if $info.item != '' }>checked<{/if}> />是
                    		&nbsp;&nbsp;
                    	    <input type="radio" name="is_send_good" id="is_send_good2" value="2" <{if $info.item == '' }>checked<{/if}> />否
                    	</div>	
                    </td>
                </tr>
                
                <{include file="tpl/send_item.tpl"}>  
            </table>
            
           
  
        </div>

        <div class="box-footer">
        	<a href="javascript:history.go(-1);" class="btn btn-default">返回</a>
            <button type="submit" name="sub" class="btn btn-default pull-right"><i class="fa fa-paper-plane-o"></i> 确定</button>
            <div style="clear: both;"></div>
        </div>
    </div>
</form>

<script type="text/javascript">
    
    $(function(){
    	<{if $info.item == '' }>
    	     $('.attach-info').hide();
    	<{/if}>
    	
    	$('#is_send_good1').on('ifChecked', function(event){
   	       $('.attach-info').show();
        });
    
        $('#is_send_good2').on('ifChecked', function(event){
   	       $('.attach-info').hide();
        });
    	
        var nameflag = true;
        var idflag = true;
        var numberflag = true;
        $('button[name="sub"]').click(function(){ 
        	var is_send_good = $('input[name="is_send_good"]:checked').val();
        	
        	var name = $('input[name="name"]').val();
        	if(name == ''){
        		layer.alert('请填写名称', {icon: 2, skin: 'layui-layer-molv'});
            	return false;
        	}
        	
        	var title = $('input[name="title"]').val();
        	if(title == ''){
        		layer.alert('请填写邮件标题', {icon: 2, skin: 'layui-layer-molv'});
            	return false;
        	}
        	
        	var content = $('textarea[name="content"]').val();
        	if(content == ''){
        		layer.alert('请填写邮件内容', {icon: 2, skin: 'layui-layer-molv'});
            	return false;
        	}
        	
        	var content_l = content.length;
        	if(content_l > 1000){
        		layer.alert('邮件内容不能超过1000字', {icon: 2, skin: 'layui-layer-molv'});
        		return false;
        	}
        	
        	$('input[name="item_name[]"]').each(function (i){
        		if($(this).val() == ''){
        			nameflag = false;
        		}else{
        			nameflag = true;
        		}
            });
            
            if(!nameflag && is_send_good == 1){
            	layer.alert('请填写道具名称', {icon: 2, skin: 'layui-layer-molv'});
            	return false;
            }

            $('input[name="item_id[]"]').each(function (i){
        		if($(this).val() == ''){
        			idflag =  false;
        		}else{
        			idflag = true;
        		}
            });
            
            if(!idflag && is_send_good == 1){
            	layer.alert('请填写道具ID', {icon: 2, skin: 'layui-layer-molv'});
            	return false;
            }
            
            $('input[name="item_number[]"]').each(function (i){
            	var max_overlap = $(this).attr('data-max');
            	_sthis = $(this);
		        var num = $(this).val();
        		if($(this).val() == ''){
        			numberflag = false;
        		}else if(parseInt(num) > parseInt(max_overlap)){
        			_sthis.val(max_overlap);
        		}else{
        			numberflag = true;
        		}
            });
            
            if(!numberflag && is_send_good == 1){
            	layer.alert('请填写道具数量', {icon: 2, skin: 'layui-layer-molv'});
            	return false;
            }
        });
        
    });
</script>




